package subdesgin;

import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Random;
import java.util.Scanner;
import java.util.Set;




public class lotteryfunc {
Scanner sc=new Scanner(System.in);


//注册
public void register(){
	
	System.out.println("请输入你的id");
    String id=sc.next();
    System.out.println("请输入你的用户名");
    
	String username=sc.next();
    System.out.println("请输入你的密码");
    String password=sc.next();
    System.out.println("请输入你的电话号码");
    String telephone=sc.next();
    System.out.println("注册成功");
	
}
public void landing(){
	Scanner sc=new Scanner(System.in);
	System.out.println("请输入你的用户名");
	String name=sc.next();
	System.out.println("请输入你的密码");
	String word=sc.next();
	
	if(name.equals("feng")&&word.equals("123"))
		System.out.println("登陆成功");
	else
		System.out.println("登陆失败");
}

//购买彩票
public   int[] buyl(){
	int[] num=new int[7];
	boolean cs=true;
	System.out.println("请选择手动选号还是随机选号");
	System.out.println("----1.手动选号--------");
	System.out.println("----2.随机选号--------");
	Scanner a=new Scanner(System.in);
	int m=a.nextInt();
	if(m==1){
		System.out.println("输入你所购买的彩票,用','隔开");
		while(cs){
		sc=new Scanner (System.in);
		String str1=sc.next();
		String[] str2 = str1.split(",");
		for(int i=0;i<str2.length;i++){
			num[i]=Integer.parseInt(str2[i]);
		}
		if(str2.length<7)
		System.out.println("输入错误,彩票数字应该为7位,请重新输入");
		
		if(str2.length==7){
		System.out.println("购买成功");
		cs=false;
		}
	    }
	}
	if(m==2){
		System.out.println("你随机选的号码为：");
		 final int N = 36;
		  final int M = 7;
		  int selected[] = new int[N];//用来记得每次选的数字表格
		  int cnt = 0;// 已选的数字个数
		  while (cnt < M) {
		   int n = (int) (Math.random() * N) + 1;
		   boolean find = false;
		   for (int i = 0; i < cnt; i++) {
		    if (selected[i] == n)  {
		     find = true;
		     break;
		    }
		   }
		   if (!find) {//表示选的n是不重复的
		    selected[cnt] = n;
		    cnt++;
		   }
		  }
		  for(int i=0;i<M;i++)//打印每次选择的数字
		   System.out.print(selected[i]+" ");     
        }
		return num;
		 
		
		 
		 
	}
	
//时间
public String buyday(){
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String strDate = sdf.format(new Date());
    return strDate;
}
//开奖
public int[] result(){
	 Set<Integer> set = new HashSet<Integer>();
	 Random a=new Random();
	 boolean fog=true;
	 while(fog){
		 int num=a.nextInt(35)+1;
		 set.add(num);
		  if(set.size()>7)
			  fog=false;
	 }
	 int[] winNo = new int[set.size()];
	    int i = 0;
	    Iterator<Integer> it = set.iterator();
	    while(it.hasNext()) {
	        winNo[i] = it.next();
	        i++;
	    }
	    return winNo;
	}
//兑奖
public int getresult(int[] buy1, int[] result) {     
   
    int sum = 0;
   
    for(int i=0; i<buy1.length; i++) {
        int n = buy1[i];           
        for(int s : result) {                
            if(n == s) {
                sum++;
            }
        }           
    }
    return sum;
}
//钱
public  int winmoney(int sum){
	int money=0;
	switch(sum){
	case 0: System.out.println("该彩票未中奖");break;
	case 1: System.out.println("该彩票未中奖");break;
	case 2: System.out.println("该彩票未中奖");break;
	case 3: System.out.println("该彩票未中奖");break;
	case 4:
		System.out.println("恭喜你中了三等奖，奖金100元");
		money=100;
		break;
	case 5: 
		System.out.println("恭喜你中了二等奖，奖金5000元");
		money=5000;
		break;
	case 6:
		System.out.println("恭喜你中了一等奖，奖金200000元");
		money=200000;
		break;
	case 7:
	   System.out.println("恭喜你中了特等奖，奖金500 0000元");
	   money=5000000;
	   break;
	}
	return money;
	
	
}
}

